<?php
/**
 * Minhlog Domain_Entity 抽象类
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 *
 * @category   Domain
 * @package    Domain_Entity
 * @copyright  Copyright (c) 2009-2010 Minh.Shu@gmail.com
 * @license    New BSD License
 * @author     Minh.Shu
 * @version    $Id: Abstract.php 2 2010-01-17 13:49:08Z Minh.Shu $
 *
 */

abstract class Domain_Entity_Abstract
{
    /**
     * 主键set抽象方法
     * @access public
     * @param integer $primaryId
     */
    abstract public function setPrimaryId ($primaryId);

    /**
     * 主键get抽象方法
     * @access public
     */
    abstract public function getPrimaryId ();

    /**
     * __set方法
     * @param $property
     * @param $value
     * @return void
     */
    public function __set($property, $value)
    {
        $method = 'set' . ucfirst($property);

        if (method_exists($this, $method)) {
            $this->$method($value);
        } else {
            throw new Exception (get_class($this) . '类的' . $property . '属性set方法未定义!');
        }
    }

    /**
     * __get方法
     * @param $property
     * @return void
     */
    public function __get($property)
    {
        $method = 'get' . ucfirst($property);

        if (method_exists($this, $method)) {
            return $this->$method();
        } else {
            throw new Exception (get_class($this) . '类的' . $property . '属性get方法未定义!');
        }
    }
}